home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb-4.5 / dist / gdb / gdb.info-1 < prev    next >
Encoding:
Text File  |  1992-04-11  |  49.5 KB  |  1,333 lines

  1. Info file ./gdb.info, produced by Makeinfo, -*- Text -*- from input
  2. file gdb-all.texi.
  3.  
  4. START-INFO-DIR-ENTRY
  5. * Gdb: (gdb).                   The GNU debugger.
  6. END-INFO-DIR-ENTRY
  7.    This file documents the GNU debugger GDB.
  8.  
  9.    This is Edition 4.04, March 1992, of `Using GDB: A Guide to the GNU
  10. Source-Level Debugger' for GDB Version 4.5.
  11.  
  12.    Copyright (C) 1988, 1989, 1990, 1991, 1992 Free Software
  13. Foundation, Inc.
  14.  
  15.    Permission is granted to make and distribute verbatim copies of
  16. this manual provided the copyright notice and this permission notice
  17. are preserved on all copies.
  18.  
  19.    Permission is granted to copy and distribute modified versions of
  20. this manual under the conditions for verbatim copying, provided also
  21. that the section entitled "GNU General Public License" is included
  22. exactly as in the original, and provided that the entire resulting
  23. derived work is distributed under the terms of a permission notice
  24. identical to this one.
  25.  
  26.    Permission is granted to copy and distribute translations of this
  27. manual into another language, under the above conditions for modified
  28. versions, except that the section entitled "GNU General Public
  29. License" may be included in a translation approved by the Free
  30. Software Foundation instead of in the original English.
  31.  
  32. 
  33. File: gdb.info,  Node: Top,  Next: Summary,  Prev: (dir),  Up: (dir)
  34.  
  35. GDB, the GNU symbolic debugger
  36. ******************************
  37.  
  38.    This file describes GDB, the GNU symbolic debugger.
  39.  
  40.    This is Edition 4.04, March 1992, for GDB Version 4.5.
  41.  
  42. * Menu:
  43.  
  44. * Summary::                     Summary of GDB
  45. * New Features::                New features since GDB version 3.5
  46. * Sample Session::              A sample GDB session
  47. * Invocation::                  Getting in and out of GDB
  48. * Commands::                    GDB commands
  49. * Running::                     Running programs under GDB
  50. * Stopping::                    Stopping and continuing
  51. * Stack::                       Examining the stack
  52. * Source::                      Examining source files
  53. * Data::                        Examining data
  54. * Languages::                   Using GDB with different languages
  55. * Symbols::                     Examining the symbol table
  56. * Altering::                    Altering execution
  57. * GDB Files::                   GDB's files
  58. * Targets::                     Specifying a debugging target
  59. * Controlling GDB::             Controlling GDB
  60. * Sequences::                   Canned sequences of commands
  61. * Emacs::                       Using GDB under GNU Emacs
  62. * GDB Bugs::                    Reporting bugs in GDB
  63. * Renamed Commands::
  64. * Formatting Documentation::    How to format and print GDB documentation
  65. * Installing GDB::              Installing GDB
  66. * Copying::                     GNU GENERAL PUBLIC LICENSE
  67. * Index::                       Index
  68.  
  69.  -- The Detailed Node Listing --
  70.  
  71. Summary of GDB
  72.  
  73. * Free Software::               Freely redistributable software
  74. * Contributors::                Contributors to GDB
  75.  
  76. Getting In and Out of GDB
  77.  
  78. * Invoking GDB::                How to start GDB
  79. * Leaving GDB::                 How to quit GDB
  80. * Shell Commands::              How to use shell commands inside GDB
  81.  
  82. Starting GDB
  83.  
  84. * File Options::                Choosing Files
  85. * Mode Options::                Choosing Modes
  86.  
  87. GDB Commands
  88.  
  89. * Command Syntax::              Command Syntax
  90. * Help::                        Getting Help
  91.  
  92. Running Programs Under GDB
  93.  
  94. * Compilation::                 Compiling for Debugging
  95. * Starting::                    Starting your Program
  96. * Arguments::                   Your Program's Arguments
  97. * Environment::                 Your Program's Environment
  98. * Working Directory::           Your Program's Working Directory
  99. * Input/Output::                Your Program's Input and Output
  100. * Attach::                      Debugging an Already-Running Process
  101. * Kill Process::                Killing the Child Process
  102. * Process Information::         Additional Process Information
  103.  
  104. Stopping and Continuing
  105.  
  106. * Breakpoints::                 Breakpoints, Watchpoints, and Exceptions
  107. * Continuing and Stepping::     Resuming Execution
  108. * Signals::                     Signals
  109.  
  110. Breakpoints, Watchpoints, and Exceptions
  111.  
  112. * Set Breaks::                  Setting Breakpoints
  113. * Set Watchpoints::             Setting Watchpoints
  114. * Exception Handling::          Breakpoints and Exceptions
  115. * Delete Breaks::               Deleting Breakpoints
  116. * Disabling::                   Disabling Breakpoints
  117. * Conditions::                  Break Conditions
  118. * Break Commands::              Breakpoint Command Lists
  119. * Breakpoint Menus::            Breakpoint Menus
  120. * Error in Breakpoints::        "Cannot insert breakpoints"
  121.  
  122. Examining the Stack
  123.  
  124. * Frames::                      Stack Frames
  125. * Backtrace::                   Backtraces
  126. * Selection::                   Selecting a Frame
  127. * Frame Info::                  Information on a Frame
  128.  
  129. Examining Source Files
  130.  
  131. * List::                        Printing Source Lines
  132. * Search::                      Searching Source Files
  133. * Source Path::                 Specifying Source Directories
  134. * Machine Code::                Source and Machine Code
  135.  
  136. Examining Data
  137.  
  138. * Expressions::                 Expressions
  139. * Variables::                   Program Variables
  140. * Arrays::                      Artificial Arrays
  141. * Output formats::              Output formats
  142. * Memory::                      Examining Memory
  143. * Auto Display::                Automatic Display
  144. * Print Settings::              Print Settings
  145. * Value History::               Value History
  146. * Convenience Vars::            Convenience Variables
  147. * Registers::                   Registers
  148. * Floating Point Hardware::     Floating Point Hardware
  149.  
  150. Using GDB with Different Languages
  151.  
  152. * Setting::                     Switching between source languages
  153. * Show::                        Displaying the language
  154. * Checks::                      Type and Range checks
  155. * Support::                     Supported languages
  156.  
  157. Switching between source languages
  158.  
  159. * Manually::                    Setting the working language manually
  160. * Automatically::               Having GDB infer the source language
  161.  
  162. Type and range Checking
  163.  
  164. * Type Checking::               An overview of type checking
  165. * Range Checking::              An overview of range checking
  166.  
  167. Supported Languages
  168.  
  169. * C::                           C and C++
  170. * Modula-2::                    Modula-2
  171.  
  172. C and C++
  173.  
  174. * C Operators::                 C and C++ Operators
  175. * C Constants::                 C and C++ Constants
  176. * Cplusplus expressions::       C++ Expressions
  177. * C Defaults::                  Default settings for C and C++
  178. * C Checks::                    C and C++ Type and Range Checks
  179. * Debugging C::                 GDB and C
  180. * Debugging C plus plus::       Special features for C++
  181.  
  182. Modula-2
  183.  
  184. * M2 Operators::                Built-in operators
  185. * Built-In Func/Proc::           Built-in Functions and Procedures
  186. * M2 Constants::                Modula-2 Constants
  187. * M2 Defaults::                 Default settings for Modula-2
  188. * Deviations::                  Deviations from standard Modula-2
  189. * M2 Checks::                   Modula-2 Type and Range Checks
  190. * M2 Scope::                    The scope operators `::' and `.'
  191. * GDB/M2::                      GDB and Modula-2
  192.  
  193. Altering Execution
  194.  
  195. * Assignment::                  Assignment to Variables
  196. * Jumping::                     Continuing at a Different Address
  197. * Signaling::                   Giving your program a Signal
  198. * Returning::                   Returning from a Function
  199. * Calling::                     Calling your Program's Functions
  200. * Patching::                    Patching your Program
  201.  
  202. GDB's Files
  203.  
  204. * Files::                       Commands to Specify Files
  205. * Symbol Errors::               Errors Reading Symbol Files
  206.  
  207. Specifying a Debugging Target
  208.  
  209. * Active Targets::              Active Targets
  210. * Target Commands::             Commands for Managing Targets
  211. * Remote::                      Remote Debugging
  212.  
  213. Remote Debugging
  214.  
  215. * i960-Nindy Remote::           GDB with a Remote i960 (Nindy)
  216. * EB29K Remote::                GDB with a Remote EB29K
  217. * VxWorks Remote::              GDB and VxWorks
  218.  
  219. GDB with a Remote i960 (Nindy)
  220.  
  221. * Nindy Startup::               Startup with Nindy
  222. * Nindy Options::               Options for Nindy
  223. * Nindy reset::                 Nindy Reset Command
  224.  
  225. GDB with a Remote EB29K
  226.  
  227. * Comms (EB29K)::               Communications Setup
  228. * gdb-EB29K::                   EB29K cross-debugging
  229. * Remote Log::                  Remote Log
  230.  
  231. GDB and VxWorks
  232.  
  233. * VxWorks connection::          Connecting to VxWorks
  234. * VxWorks download::            VxWorks Download
  235. * VxWorks attach::              Running Tasks
  236.  
  237. Controlling GDB
  238.  
  239. * Prompt::                      Prompt
  240. * Editing::                     Command Editing
  241. * History::                     Command History
  242. * Screen Size::                 Screen Size
  243. * Numbers::                     Numbers
  244. * Messages/Warnings::           Optional Warnings and Messages
  245.  
  246. Canned Sequences of Commands
  247.  
  248. * Define::                      User-Defined Commands
  249. * Command Files::               Command Files
  250. * Output::                      Commands for Controlled Output
  251.  
  252. Reporting Bugs in GDB
  253.  
  254. * Bug Criteria::                Have You Found a Bug?
  255. * Bug Reporting::               How to Report Bugs
  256.  
  257. Installing GDB
  258.  
  259. * Separate Objdir::             Compiling GDB in another directory
  260. * Config Names::                Specifying names for hosts and targets
  261. * configure Options::           Summary of options for configure
  262.  
  263. 
  264. File: gdb.info,  Node: Summary,  Next: New Features,  Prev: Top,  Up: Top
  265.  
  266. Summary of GDB
  267. **************
  268.  
  269.    The purpose of a debugger such as GDB is to allow you to see what is
  270. going on "inside" another program while it executes--or what another
  271. program was doing at the moment it crashed.
  272.  
  273.    GDB can do four main kinds of things (plus other things in support
  274. of these) to help you catch bugs in the act:
  275.  
  276.    * Start your program, specifying anything that might affect its
  277.      behavior.
  278.  
  279.    * Make your program stop on specified conditions.
  280.  
  281.    * Examine what has happened, when your program has stopped.
  282.  
  283.    * Change things in your program, so you can experiment with
  284.      correcting the effects of one bug and go on to learn about
  285.      another.
  286.  
  287.    You can use GDB to debug programs written in C, C++, and Modula-2. 
  288. Fortran support will be added when a GNU Fortran compiler is ready.
  289.  
  290. * Menu:
  291.  
  292. * Free Software::               Free Software
  293. * Contributors::                Contributors to GDB
  294.  
  295. 
  296. File: gdb.info,  Node: Free Software,  Next: Contributors,  Prev: Summary,  Up: Summary
  297.  
  298. Free Software
  299. =============
  300.  
  301.    GDB is "free software", protected by the GNU General Public License
  302. (GPL).  The GPL gives you the freedom to copy or adapt a licensed
  303. program--but every person getting a copy also gets with it the freedom
  304. to modify that copy (which means that they must get access to the
  305. source code), and the freedom to distribute further copies.  Typical
  306. software companies use copyrights to limit your freedoms; the Free
  307. Software Foundation uses the GPL to preserve these freedoms.
  308.  
  309.    Fundamentally, the General Public License is a license which says
  310. that you have these freedoms and that you cannot take these freedoms
  311. away from anyone else.
  312.  
  313.    For full details, *note GNU GENERAL PUBLIC LICENSE: Copying..
  314.  
  315. 
  316. File: gdb.info,  Node: Contributors,  Prev: Free Software,  Up: Summary
  317.  
  318. Contributors to GDB
  319. ===================
  320.  
  321.    Richard Stallman was the original author of GDB, and of many other
  322. GNU programs.  Many others have contributed to its development.  This
  323. section attempts to credit major contributors.  One of the virtues of
  324. free software is that everyone is free to contribute to it; with
  325. regret, we cannot actually acknowledge everyone here.  The file
  326. `ChangeLog' in the GDB distribution approximates a blow-by-blow
  327. account.
  328.  
  329.    Changes much prior to version 2.0 are lost in the mists of time.
  330.  
  331.      *Plea:* Additions to this section are particularly welcome.  If
  332.      you or your friends (or enemies; let's be evenhanded) have been
  333.      unfairly omitted from this list, we would like to add your names!
  334.  
  335.    So that they may not regard their long labor as thankless, we
  336. particularly thank those who shepherded GDB through major releases: Stu
  337. Grossman and John Gilmore (releases 4.5, 4.4), John Gilmore (releases
  338. 4.3, 4.2, 4.1, 4.0, and 3.9); Jim Kingdon (releases 3.5, 3.4, 3.3);
  339. and Randy Smith (releases 3.2, 3.1, 3.0).  As major maintainer of GDB
  340. for some period, each contributed significantly to the structure,
  341. stability, and capabilities of the entire debugger.
  342.  
  343.    Richard Stallman, assisted at various times by Pete TerMaat, Chris
  344. Hanson, and Richard Mlynarik, handled releases through 2.8.
  345.  
  346.    Michael Tiemann is the author of most of the GNU C++ support in GDB,
  347. with significant additional contributions from Per Bothner.  James
  348. Clark wrote the GNU C++ demangler.  Early work on C++ was by Peter
  349. TerMaat (who also did much general update work leading to release 3.0).
  350.  
  351.    GDB 4 uses the BFD subroutine library to examine multiple
  352. object-file formats; BFD was a joint project of David V. 
  353. Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.
  354.  
  355.    David Johnson wrote the original COFF support; Pace Willison did
  356. the original support for encapsulated COFF.
  357.  
  358.    Adam de Boor and Bradley Davis contributed the ISI Optimum V
  359. support.  Per Bothner, Noboyuki Hikichi, and Alessandro Forin
  360. contributed MIPS support.  Jean-Daniel Fekete contributed Sun 386i
  361. support.  Chris Hanson improved the HP9000 support.  Noboyuki Hikichi
  362. and Tomoyuki Hasei contributed Sony/News OS 3 support.  David Johnson
  363. contributed Encore Umax support.  Jyrki Kuoppala contributed Altos
  364. 3068 support.  Keith Packard contributed NS32K support.  Doug Rabson
  365. contributed Acorn Risc Machine support.  Chris Smith contributed
  366. Convex support (and Fortran debugging).  Jonathan Stone contributed
  367. Pyramid support.  Michael Tiemann contributed SPARC support.  Tim
  368. Tucker contributed support for the Gould NP1 and Gould Powernode. 
  369. Pace Willison contributed Intel 386 support.  Jay Vosburgh contributed
  370. Symmetry support.
  371.  
  372.    Rich Schaefer and Peter Schauer helped with support of SunOS shared
  373. libraries.
  374.  
  375.    Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about
  376. several machine instruction sets.
  377.  
  378.    Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped
  379. develop remote debugging.  Intel Corporation and Wind River Systems
  380. contributed remote debugging modules for their products.
  381.  
  382.    Brian Fox is the author of the readline libraries providing
  383. command-line editing and command history.
  384.  
  385.    Andrew Beers of SUNY Buffalo wrote the language-switching code and
  386. the Modula-2 support, and contributed the Languages chapter of this
  387. manual.
  388.  
  389.    Fred Fish wrote most of the support for Unix System Vr4.
  390.  
  391. 
  392. File: gdb.info,  Node: New Features,  Next: Sample Session,  Prev: Summary,  Up: Top
  393.  
  394. New Features since GDB version 3.5
  395. **********************************
  396.  
  397. *Targets*
  398.      Using the new command `target', you can select at runtime whether
  399.      you are debugging local files, local processes, standalone
  400.      systems over a serial port, realtime systems over a TCP/IP
  401.      connection, etc.  The command `load' can download programs into a
  402.      remote system.  Serial stubs are available for Motorola 680x0 and
  403.      Intel 80386 remote systems; GDB also supports debugging realtime
  404.      processes running under VxWorks, using SunRPC Remote Procedure
  405.      Calls over TCP/IP to talk to a debugger stub on the target
  406.      system.  Internally, GDB now uses a function vector to mediate
  407.      access to different targets; if you need to add your own support
  408.      for a remote protocol, this makes it much easier.
  409.  
  410. *Watchpoints*
  411.      GDB now sports watchpoints as well as breakpoints.  You can use a
  412.      watchpoint to stop execution whenever the value of an expression
  413.      changes, without having to predict a particular place in your
  414.      program where this may happen.
  415.  
  416. *Wide Output*
  417.      Commands that issue wide output now insert newlines at places
  418.      designed to make the output more readable.
  419.  
  420. *Object Code Formats*
  421.      GDB uses a new library called the Binary File Descriptor (BFD)
  422.      Library to permit it to switch dynamically, without
  423.      reconfiguration or recompilation, between different object-file
  424.      formats.  Formats currently supported are COFF, a.out, and the
  425.      Intel 960 b.out; files may be read as .o's, archive libraries, or
  426.      core dumps.  BFD is available as a subroutine library so that
  427.      other programs may take advantage of it, and the other GNU binary
  428.      utilities are being converted to use it.
  429.  
  430. *Configuration and Ports*
  431.      Compile-time configuration (to select a particular architecture
  432.      and operating system) is much easier.  The script `configure' now
  433.      allows you to configure GDB as either a native debugger or a
  434.      cross-debugger. *Note Installing GDB::, for details on how to
  435.      configure and on what architectures are now available.
  436.  
  437. *Interaction*
  438.      The user interface to GDB's control variables has been simplified
  439.      and consolidated in two commands, `set' and `show'.  Output lines
  440.      are now broken at readable places, rather than overflowing onto
  441.      the next line.  You can suppress output of machine-level
  442.      addresses, displaying only source language information.
  443.  
  444. *C++*
  445.      GDB now supports C++ multiple inheritance (if used with a GCC
  446.      version 2 compiler), and also has limited support for C++
  447.      exception handling, with the commands `catch' and `info catch':
  448.      GDB can break when an exception is raised, before the stack is
  449.      peeled back to the exception handler's context.
  450.  
  451. *Modula-2*
  452.      GDB now has preliminary support for the GNU Modula-2 compiler,
  453.      currently under development at the State University of New York at
  454.      Buffalo.  Coordinated development of both GDB and the GNU Modula-2
  455.      compiler will continue into 1992.  Other Modula-2 compilers are
  456.      currently not supported, and attempting to debug programs
  457.      compiled with them will likely result in an error as the symbol
  458.      table of the executable is read in.
  459.  
  460. *Command Rationalization*
  461.      Many GDB commands have been renamed to make them easier to
  462.      remember and use.  In particular, the subcommands of `info' and
  463.      `show'/`set' are grouped to make the former refer to the state of
  464.      your program, and the latter refer to the state of GDB itself. 
  465.      *Note Renamed Commands::, for details on what commands were
  466.      renamed.
  467.  
  468. *Shared Libraries*
  469.      GDB 4 can debug programs and core files that use SunOS, SVR4, or
  470.      IBM RS/6000 shared libraries.
  471.  
  472. *Reference Card*
  473.      GDB 4 has a reference card.  *Note Formatting Documentation:: for
  474.      instructions on printing it.
  475.  
  476. *Work in Progress*
  477.      Kernel debugging for BSD and Mach systems; Tahoe and HPPA
  478.      architecture support.
  479.  
  480. 
  481. File: gdb.info,  Node: Sample Session,  Next: Invocation,  Prev: New Features,  Up: Top
  482.  
  483. A Sample GDB Session
  484. ********************
  485.  
  486.    You can use this manual at your leisure to read all about GDB. 
  487. However, a handful of commands are enough to get started using the
  488. debugger.  This chapter illustrates these commands.
  489.  
  490.    One of the preliminary versions of GNU `m4' (a generic macro
  491. processor) exhibits the following bug: sometimes, when we change its
  492. quote strings from the default, the commands used to capture one
  493. macro's definition in another stop working.  In the following short
  494. `m4' session, we define a macro `foo' which expands to `0000'; we then
  495. use the `m4' built-in `defn' to define `bar' as the same thing. 
  496. However, when we change the open quote string to `<QUOTE>' and the
  497. close quote string to `<UNQUOTE>', the same procedure fails to define
  498. a new synonym `baz':
  499.  
  500.      $ cd gnu/m4
  501.      $ ./m4
  502.      define(foo,0000)
  503.      
  504.      foo
  505.      0000
  506.      define(bar,defn(`foo'))
  507.      
  508.      bar
  509.      0000
  510.      changequote(<QUOTE>,<UNQUOTE>)
  511.      
  512.      define(baz,defn(<QUOTE>foo<UNQUOTE>))
  513.      baz
  514.      C-d
  515.      m4: End of input: 0: fatal error: EOF in string
  516.  
  517. Let's use GDB to try to see what's going on.
  518.  
  519.      $ gdb m4
  520.      GDB is free software and you are welcome to distribute copies
  521.       of it under certain conditions; type "show copying" to see
  522.       the conditions.
  523.      There is absolutely no warranty for GDB; type "show warranty"
  524.      for details.
  525.      GDB 4.5, Copyright 1992 Free Software Foundation, Inc...
  526.      (gdb)
  527.  
  528. GDB reads only enough symbol data to know where to find the rest when
  529. needed; as a result, the first prompt comes up very quickly.  We now
  530. tell GDB to use a narrower display width than usual, so that examples
  531. will fit in this manual.
  532.  
  533.      (gdb) set width 70
  534.  
  535. Let's see how the `m4' built-in `changequote' works.  Having looked at
  536. the source, we know the relevant subroutine is `m4_changequote', so we
  537. set a breakpoint there with GDB's `break' command.
  538.  
  539.      (gdb) break m4_changequote
  540.      Breakpoint 1 at 0x62f4: file builtin.c, line 879.
  541.  
  542. Using the `run' command, we start `m4' running under GDB control; as
  543. long as control does not reach the `m4_changequote' subroutine, the
  544. program runs as usual:
  545.  
  546.      (gdb) run
  547.      Starting program: /work/Editorial/gdb/gnu/m4/m4
  548.      define(foo,0000)
  549.      
  550.      foo
  551.      0000
  552.  
  553. To trigger the breakpoint, we call `changequote'.  GDB suspends
  554. execution of `m4', displaying information about the context where it
  555. stops.
  556.  
  557.      changequote(<QUOTE>,<UNQUOTE>)
  558.      
  559.      Breakpoint 1, m4_changequote (argc=3, argv=0x33c70)
  560.          at builtin.c:879
  561.      879         if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3))
  562.  
  563. Now we use the command `n' (`next') to advance execution to the next
  564. line of the current function.
  565.  
  566.      (gdb) n
  567.      882         set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\
  568.       : nil,
  569.  
  570. `set_quotes' looks like a promising subroutine.  We can go into it by
  571. using the command `s' (`step') instead of `next'.  `step' goes to the
  572. next line to be executed in *any* subroutine, so it steps into
  573. `set_quotes'.
  574.  
  575.      (gdb) s
  576.      set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  577.          at input.c:530
  578.      530         if (lquote != def_lquote)
  579.  
  580. The display that shows the subroutine where `m4' is now suspended (and
  581. its arguments) is called a stack frame display.  It shows a summary of
  582. the stack.  We can use the `backtrace' command (which can also be
  583. spelled `bt'), to see where we are in the stack as a whole: the
  584. `backtrace' command displays a stack frame for each active subroutine.
  585.  
  586.      (gdb) bt
  587.      #0  set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  588.          at input.c:530
  589.      #1  0x6344 in m4_changequote (argc=3, argv=0x33c70)
  590.          at builtin.c:882
  591.      #2  0x8174 in expand_macro (sym=0x33320) at macro.c:242
  592.      #3  0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
  593.          at macro.c:71
  594.      #4  0x79dc in expand_input () at macro.c:40
  595.      #5  0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
  596.  
  597. Let's step through a few more lines to see what happens.  The first two
  598. times, we can use `s'; the next two times we use `n' to avoid falling
  599. into the `xstrdup' subroutine.
  600.  
  601.      (gdb) s
  602.      0x3b5c  532         if (rquote != def_rquote)
  603.      (gdb) s
  604.      0x3b80  535         lquote = (lq == nil || *lq == '\0') ?  \
  605.      def_lquote : xstrdup(lq);
  606.      (gdb) n
  607.      536         rquote = (rq == nil || *rq == '\0') ? def_rquote\
  608.       : xstrdup(rq);
  609.      (gdb) n
  610.      538         len_lquote = strlen(rquote);
  611.  
  612. The last line displayed looks a little odd; let's examine the variables
  613. `lquote' and `rquote' to see if they are in fact the new left and
  614. right quotes we specified.  We can use the command `p' (`print') to
  615. see their values.
  616.  
  617.      (gdb) p lquote
  618.      $1 = 0x35d40 "<QUOTE>"
  619.      (gdb) p rquote
  620.      $2 = 0x35d50 "<UNQUOTE>"
  621.  
  622. `lquote' and `rquote' are indeed the new left and right quotes.  Let's
  623. look at some context; we can display ten lines of source surrounding
  624. the current line, with the `l' (`list') command.
  625.  
  626.      (gdb) l
  627.      533             xfree(rquote);
  628.      534
  629.      535         lquote = (lq == nil || *lq == '\0') ? def_lquote\
  630.       : xstrdup (lq);
  631.      536         rquote = (rq == nil || *rq == '\0') ? def_rquote\
  632.       : xstrdup (rq);
  633.      537
  634.      538         len_lquote = strlen(rquote);
  635.      539         len_rquote = strlen(lquote);
  636.      540     }
  637.      541
  638.      542     void
  639.  
  640. Let's step past the two lines that set `len_lquote' and `len_rquote',
  641. and then examine the values of those variables.
  642.  
  643.      (gdb) n
  644.      539         len_rquote = strlen(lquote);
  645.      (gdb) n
  646.      540     }
  647.      (gdb) p len_lquote
  648.      $3 = 9
  649.      (gdb) p len_rquote
  650.      $4 = 7
  651.  
  652. That certainly looks wrong, assuming `len_lquote' and `len_rquote' are
  653. meant to be the lengths of `lquote' and `rquote' respectively.  Let's
  654. try setting them to better values.  We can use the `p' command for
  655. this, since it'll print the value of any expression--and that
  656. expression can include subroutine calls and assignments.
  657.  
  658.      (gdb) p len_lquote=strlen(lquote)
  659.      $5 = 7
  660.      (gdb) p len_rquote=strlen(rquote)
  661.      $6 = 9
  662.  
  663. Let's see if that fixes the problem of using the new quotes with the
  664. `m4' built-in `defn'.  We can allow `m4' to continue executing with
  665. the `c' (`continue') command, and then try the example that caused
  666. trouble initially:
  667.  
  668.      (gdb) c
  669.      Continuing.
  670.      
  671.      define(baz,defn(<QUOTE>foo<UNQUOTE>))
  672.      
  673.      baz
  674.      0000
  675.  
  676. Success!  The new quotes now work just as well as the default ones. 
  677. The problem seems to have been just the two typos defining the wrong
  678. lengths.  We'll let `m4' exit by giving it an EOF as input.
  679.  
  680.      C-d
  681.      Program exited normally.
  682.  
  683. The message `Program exited normally.' is from GDB; it indicates `m4'
  684. has finished executing.  We can end our GDB session with the GDB
  685. `quit' command.
  686.  
  687.      (gdb) quit
  688.  
  689. 
  690. File: gdb.info,  Node: Invocation,  Next: Commands,  Prev: Sample Session,  Up: Top
  691.  
  692. Getting In and Out of GDB
  693. *************************
  694.  
  695.    This chapter discusses how to start GDB, and how to get out of it. 
  696. (The essentials: type `gdb' to start GDB, and type `quit' or `C-d' to
  697. exit.)
  698.  
  699. * Menu:
  700.  
  701. * Invoking GDB::                Starting GDB
  702. * Leaving GDB::                 Leaving GDB
  703. * Shell Commands::              Shell Commands
  704.  
  705. 
  706. File: gdb.info,  Node: Invoking GDB,  Next: Leaving GDB,  Prev: Invocation,  Up: Invocation
  707.  
  708. Starting GDB
  709. ============
  710.  
  711.    Start GDB with the shell command `gdb'.  Once it's running, GDB
  712. reads commands from the terminal until you tell it to exit.
  713.  
  714.    You can also run `gdb' with a variety of arguments and options, to
  715. specify more of your debugging environment at the outset.
  716.  
  717.    The command-line options described here are designed to cover a
  718. variety of situations; in some environments, some of these options may
  719. effectively be unavailable.
  720.  
  721.    The most usual way to start GDB is with one argument or two,
  722. specifying an executable program as the argument:
  723.  
  724.      gdb PROGRAM
  725.  
  726. You can also start with both an executable program and a core file
  727. specified:
  728.  
  729.      gdb PROGRAM CORE
  730.  
  731.    You can, instead, specify a process ID as a second argument, if you
  732. want to debug a running process:
  733.  
  734.      gdb PROGRAM 1234
  735.  
  736. would attach GDB to process `1234' (unless you also have a file named
  737. `1234'; GDB does check for a core file first).
  738.  
  739.    Taking advantage of the second command-line argument requires a
  740. fairly complete operating system; when you use GDB as a remote debugger
  741. attached to a bare board, there may not be any notion of "process",
  742. and there is often no way to get a core dump.
  743.  
  744. You can further control how GDB starts up by using command-line
  745. options.  GDB itself can remind you of the options available.
  746.  
  747. Type
  748.  
  749.      gdb -help
  750.  
  751. to display all available options and briefly describe their use (`gdb
  752. -h' is a shorter equivalent).
  753.  
  754.    All options and command line arguments you give are processed in
  755. sequential order.  The order makes a difference when the `-x' option
  756. is used.
  757.  
  758. * Menu:
  759.  
  760. * File Options::                Choosing Files
  761. * Mode Options::                Choosing Modes
  762.  
  763. 
  764. File: gdb.info,  Node: File Options,  Next: Mode Options,  Prev: Invoking GDB,  Up: Invoking GDB
  765.  
  766. Choosing Files
  767. --------------
  768.  
  769.    When GDB starts, it reads any arguments other than options as
  770. specifying an executable file and core file (or process ID).  This is
  771. the same as if the arguments were specified by the `-se' and `-c'
  772. options respectively.  (GDB reads the first argument that does not
  773. have an associated option flag as equivalent to the `-se' option
  774. followed by that argument; and the second argument that does not have
  775. an associated option flag, if any, as equivalent to the `-c' option
  776. followed by that argument.)
  777.  
  778.    Many options have both long and short forms; both are shown in the
  779. following list.  GDB also recognizes the long forms if you truncate
  780. them, so long as enough of the option is present to be unambiguous. 
  781. (If you prefer, you can flag option arguments with `--' rather than
  782. `-', though we illustrate the more usual convention.)
  783.  
  784. `-symbols=FILE'
  785. `-s FILE'
  786.      Read symbol table from file FILE.
  787.  
  788. `-exec=FILE'
  789. `-e FILE'
  790.      Use file FILE as the executable file to execute when appropriate,
  791.      and for examining pure data in conjunction with a core dump.
  792.  
  793. `-se=FILE'
  794.      Read symbol table from file FILE and use it as the executable
  795.      file.
  796.  
  797. `-core=FILE'
  798. `-c FILE'
  799.      Use file FILE as a core dump to examine.
  800.  
  801. `-command=FILE'
  802. `-x FILE'
  803.      Execute GDB commands from file FILE.  *Note Command Files::.
  804.  
  805. `-directory=DIRECTORY'
  806. `-d DIRECTORY'
  807.      Add DIRECTORY to the path to search for source files.
  808.  
  809. `-m'
  810. `-mapped'
  811.      *Warning: this option depends on operating system facilities that
  812.      are not supported on all systems.*
  813.       If memory-mapped files are available on your system through the
  814.      `mmap' system call, you can use this option to cause GDB to write
  815.      the symbols from your program into a reusable file in the current
  816.      directory.  If the program you are debugging is called
  817.      `/tmp/fred', the mapped symbol file will be `./fred.syms'. 
  818.      Future GDB debugging sessions will notice the presence of this
  819.      file, and will quickly map in symbol information from it, rather
  820.      than reading the symbol table from the executable program.
  821.  
  822.      The `.syms' file is specific to the host machine on which GDB is
  823.      run.  It holds an exact image of GDB's internal symbol table.  It
  824.      cannot be shared across multiple host platforms.
  825.  
  826. `-r'
  827. `-readnow'
  828.      Read each symbol file's entire symbol table immediately, rather
  829.      than the default, which is to read it incrementally as it is
  830.      needed.  This makes startup slower, but makes future operations
  831.      faster.
  832.  
  833.    The `-mapped' and `-readnow' options are typically combined in
  834. order to build a `.syms' file that contains complete symbol
  835. information.  A simple GDB invocation to do nothing but build a
  836. `.syms' file for future use is:
  837.  
  838.          gdb -batch -nx -mapped -readnow programname
  839.  
  840. 
  841. File: gdb.info,  Node: Mode Options,  Prev: File Options,  Up: Invoking GDB
  842.  
  843. Choosing Modes
  844. --------------
  845.  
  846.    You can run GDB in various alternative modes--for example, in batch
  847. mode or quiet mode.
  848.  
  849. `-nx'
  850. `-n'
  851.      Do not execute commands from any `.gdbinit' initialization files. 
  852.      Normally, the commands in these files are executed after all the
  853.      command options and arguments have been processed.  *Note Command
  854.      Files::.
  855.  
  856. `-quiet'
  857. `-q'
  858.      "Quiet".  Do not print the introductory and copyright messages. 
  859.      These messages are also suppressed in batch mode.
  860.  
  861. `-batch'
  862.      Run in batch mode.  Exit with status `0' after processing all the
  863.      command files specified with `-x' (and `.gdbinit', if not
  864.      inhibited).  Exit with nonzero status if an error occurs in
  865.      executing the GDB commands in the command files.
  866.  
  867.      Batch mode may be useful for running GDB as a filter, for example
  868.      to download and run a program on another computer; in order to
  869.      make this more useful, the message
  870.  
  871.           Program exited normally.
  872.  
  873.      (which is ordinarily issued whenever a program running under GDB
  874.      control terminates) is not issued when running in batch mode.
  875.  
  876. `-cd=DIRECTORY'
  877.      Run GDB using DIRECTORY as its working directory, instead of the
  878.      current directory.
  879.  
  880. `-fullname'
  881. `-f'
  882.      Emacs sets this option when it runs GDB as a subprocess.  It
  883.      tells GDB to output the full file name and line number in a
  884.      standard, recognizable fashion each time a stack frame is
  885.      displayed (which includes each time your program stops).  This
  886.      recognizable format looks like two `\032' characters, followed by
  887.      the file name, line number and character position separated by
  888.      colons, and a newline.  The Emacs-to-GDB interface program uses
  889.      the two `\032' characters as a signal to display the source code
  890.      for the frame.
  891.  
  892. `-b BPS'
  893.      Set the line speed (baud rate or bits per second) of any serial
  894.      interface used by GDB for remote debugging.
  895.  
  896. `-tty=DEVICE'
  897.      Run using DEVICE for your program's standard input and output.
  898.  
  899. 
  900. File: gdb.info,  Node: Leaving GDB,  Next: Shell Commands,  Prev: Invoking GDB,  Up: Invocation
  901.  
  902. Leaving GDB
  903. ===========
  904.  
  905. `quit'
  906.      To exit GDB, use the `quit' command (abbreviated `q'), or type an
  907.      end-of-file character (usually `C-d').
  908.  
  909.    An interrupt (often `C-c') will not exit from GDB, but rather will
  910. terminate the action of any GDB command that is in progress and return
  911. to GDB command level.  It is safe to type the interrupt character at
  912. any time because GDB does not allow it to take effect until a time
  913. when it is safe.
  914.  
  915.    If you have been using GDB to control an attached process or
  916. device, you can release it with the `detach' command; *note Debugging
  917. an Already-Running Process: Attach...
  918.  
  919. 
  920. File: gdb.info,  Node: Shell Commands,  Prev: Leaving GDB,  Up: Invocation
  921.  
  922. Shell Commands
  923. ==============
  924.  
  925.    If you need to execute occasional shell commands during your
  926. debugging session, there is no need to leave or suspend GDB; you can
  927. just use the `shell' command.
  928.  
  929. `shell COMMAND STRING'
  930.      Directs GDB to invoke an inferior shell to execute COMMAND
  931.      STRING.  If it exists, the environment variable `SHELL' is used
  932.      for the name of the shell to run.  Otherwise GDB uses `/bin/sh'.
  933.  
  934.    The utility `make' is often needed in development environments. 
  935. You do not have to use the `shell' command for this purpose in GDB:
  936.  
  937. `make MAKE-ARGS'
  938.      Causes GDB to execute an inferior `make' program with the
  939.      specified arguments.  This is equivalent to `shell make
  940.      MAKE-ARGS'.
  941.  
  942. 
  943. File: gdb.info,  Node: Commands,  Next: Running,  Prev: Invocation,  Up: Top
  944.  
  945. GDB Commands
  946. ************
  947.  
  948.    You can abbreviate GDB command if that abbreviation is unambiguous;
  949. and you can repeat certain GDB commands by typing just RET.
  950.  
  951. * Menu:
  952.  
  953. * Command Syntax::              Command Syntax
  954. * Help::                        Getting Help
  955.  
  956. 
  957. File: gdb.info,  Node: Command Syntax,  Next: Help,  Prev: Commands,  Up: Commands
  958.  
  959. Command Syntax
  960. ==============
  961.  
  962.    A GDB command is a single line of input.  There is no limit on how
  963. long it can be.  It starts with a command name, which is followed by
  964. arguments whose meaning depends on the command name.  For example, the
  965. command `step' accepts an argument which is the number of times to
  966. step, as in `step 5'.  You can also use the `step' command with no
  967. arguments.  Some command names do not allow any arguments.
  968.  
  969.    GDB command names may always be truncated if that abbreviation is
  970. unambiguous.  Other possible command abbreviations are listed in the
  971. documentation for individual commands.  In some cases, even ambiguous
  972. abbreviations are allowed; for example, `s' is specially defined as
  973. equivalent to `step' even though there are other commands whose names
  974. start with `s'.  You can test abbreviations by using them as arguments
  975. to the `help' command.
  976.  
  977.    A blank line as input to GDB (typing just RET) means to repeat the
  978. previous command. Certain commands (for example, `run') will not
  979. repeat this way; these are commands for which unintentional repetition
  980. might cause trouble and which you are unlikely to want to repeat.
  981.  
  982.    The `list' and `x' commands, when you repeat them with RET,
  983. construct new arguments rather than repeating exactly as typed.  This
  984. permits easy scanning of source or memory.
  985.  
  986.    GDB can also use RET in another way: to partition lengthy output,
  987. in a way similar to the common utility `more' (*note Screen Size::.). 
  988. Since it is easy to press one RET too many in this situation, GDB
  989. disables command repetition after any command that generates this sort
  990. of display.
  991.  
  992.    A line of input starting with `#' is a comment; it does nothing. 
  993. This is useful mainly in command files (*note Command Files::.).
  994.  
  995. 
  996. File: gdb.info,  Node: Help,  Prev: Command Syntax,  Up: Commands
  997.  
  998. Getting Help
  999. ============
  1000.  
  1001.    You can always ask GDB itself for information on its commands,
  1002. using the command `help'.
  1003.  
  1004. `help'
  1005. `h'
  1006.      You can use `help' (abbreviated `h') with no arguments to display
  1007.      a short list of named classes of commands:
  1008.  
  1009.           (gdb) help
  1010.           List of classes of commands:
  1011.           
  1012.           running -- Running the program
  1013.           stack -- Examining the stack
  1014.           data -- Examining data
  1015.           breakpoints -- Making program stop at certain points
  1016.           files -- Specifying and examining files
  1017.           status -- Status inquiries
  1018.           support -- Support facilities
  1019.           user-defined -- User-defined commands
  1020.           aliases -- Aliases of other commands
  1021.           obscure -- Obscure features
  1022.           
  1023.           Type "help" followed by a class name for a list of
  1024.           commands in that class.
  1025.           Type "help" followed by command name for full
  1026.           documentation.
  1027.           Command name abbreviations are allowed if unambiguous.
  1028.           (gdb)
  1029.  
  1030. `help CLASS'
  1031.      Using one of the general help classes as an argument, you can get
  1032.      a list of the individual commands in that class.  For example,
  1033.      here is the help display for the class `status':
  1034.  
  1035.           (gdb) help status
  1036.           Status inquiries.
  1037.           
  1038.           List of commands:
  1039.           
  1040.           show -- Generic command for showing things set with "set"
  1041.           info -- Generic command for printing status
  1042.           
  1043.           Type "help" followed by command name for full
  1044.           documentation.
  1045.           Command name abbreviations are allowed if unambiguous.
  1046.           (gdb)
  1047.  
  1048. `help COMMAND'
  1049.      With a command name as `help' argument, GDB will display a short
  1050.      paragraph on how to use that command.
  1051.  
  1052.    In addition to `help', you can use the GDB commands `info' and
  1053. `show' to inquire about the state of your program, or the state of GDB
  1054. itself.  Each command supports many topics of inquiry; this manual
  1055. introduces each of them in the appropriate context.  The listings
  1056. under `info' and under `show' in the Index point to all the
  1057. sub-commands.  *Note Index::.
  1058.  
  1059. `info'
  1060.      This command (abbreviated `i') is for describing the state of your
  1061.      program; for example, it can list the arguments given to your
  1062.      program (`info args'), the registers currently in use (`info
  1063.      registers'), or the breakpoints you have set (`info breakpoints'). 
  1064.      You can get a complete list of the `info' sub-commands with
  1065.      `help info'.
  1066.  
  1067. `show'
  1068.      In contrast, `show' is for describing the state of GDB itself. 
  1069.      You can change most of the things you can `show', by using the
  1070.      related command `set'; for example, you can control what number
  1071.      system is used for displays with `set radix', or simply inquire
  1072.      which is currently in use with `show radix'.
  1073.  
  1074.      To display all the settable parameters and their current values,
  1075.      you can use `show' with no arguments; you may also use `info
  1076.      set'.  Both commands produce the same display.
  1077.  
  1078.    Here are three miscellaneous `show' subcommands, all of which are
  1079. exceptional in lacking corresponding `set' commands:
  1080.  
  1081. `show version'
  1082.      Show what version of GDB is running.  You should include this
  1083.      information in GDB bug-reports.  If multiple versions of GDB are
  1084.      in use at your site, you may occasionally want to make sure what
  1085.      version of GDB you are running; as GDB evolves, new commands are
  1086.      introduced, and old ones may wither away.  The version number is
  1087.      also announced when you start GDB with no arguments.
  1088.  
  1089. `show copying'
  1090.      Display information about permission for copying GDB.
  1091.  
  1092. `show warranty'
  1093.      Display the GNU "NO WARRANTY" statement.
  1094.  
  1095. 
  1096. File: gdb.info,  Node: Running,  Next: Stopping,  Prev: Commands,  Up: Top
  1097.  
  1098. Running Programs Under GDB
  1099. **************************
  1100.  
  1101.    To debug a program, you must run it under GDB.
  1102.  
  1103. * Menu:
  1104.  
  1105. * Compilation::                 Compiling for Debugging
  1106. * Starting::                    Starting your Program
  1107. * Arguments::                   Your Program's Arguments
  1108. * Environment::                 Your Program's Environment
  1109. * Working Directory::           Your Program's Working Directory
  1110. * Input/Output::                Your Program's Input and Output
  1111. * Attach::                      Debugging an Already-Running Process
  1112. * Kill Process::                Killing the Child Process
  1113. * Process Information::         Additional Process Information
  1114.  
  1115. 
  1116. File: gdb.info,  Node: Compilation,  Next: Starting,  Prev: Running,  Up: Running
  1117.  
  1118. Compiling for Debugging
  1119. =======================
  1120.  
  1121.    In order to debug a program effectively, you need to generate
  1122. debugging information when you compile it.  This debugging information
  1123. is stored in the object file; it describes the data type of each
  1124. variable or function and the correspondence between source line numbers
  1125. and addresses in the executable code.
  1126.  
  1127.    To request debugging information, specify the `-g' option when you
  1128. run the compiler.
  1129.  
  1130.    Many C compilers are unable to handle the `-g' and `-O' options
  1131. together.  Using those compilers, you cannot generate optimized
  1132. executables containing debugging information.
  1133.  
  1134.    gcc, the GNU C compiler, supports `-g' with or without `-O', making
  1135. it possible to debug optimized code.  We recommend that you *always*
  1136. use `-g' whenever you compile a program.  You may think your program
  1137. is correct, but there is no sense in pushing your luck.
  1138.  
  1139.    When you debug a program compiled with `-g -O', remember that the
  1140. optimizer is rearranging your code; the debugger will show you what's
  1141. really there.  Don't be too surprised when the execution path doesn't
  1142. exactly match your source file!  An extreme example: if you define a
  1143. variable, but never use it, GDB will never see that variable--because
  1144. the compiler optimizes it out of existence.
  1145.  
  1146.    Some things do not work as well with `-g -O' as with just `-g',
  1147. particularly on machines with instruction scheduling.  If in doubt,
  1148. recompile with `-g' alone, and if this fixes the problem, please
  1149. report it as a bug (including a test case!).
  1150.  
  1151.    Older versions of the GNU C compiler permitted a variant option
  1152. `-gg' for debugging information.  GDB no longer supports this format;
  1153. if your GNU C compiler has this option, do not use it.
  1154.  
  1155. 
  1156. File: gdb.info,  Node: Starting,  Next: Arguments,  Prev: Compilation,  Up: Running
  1157.  
  1158. Starting your Program
  1159. =====================
  1160.  
  1161. `run'
  1162. `r'
  1163.      Use the `run' command to start your program under GDB.  You must
  1164.      first specify the program name (except on VxWorks) with an
  1165.      argument to GDB (*note Getting In and Out of GDB: Invocation.),
  1166.      or by using the `file' or `exec-file' command (*note Commands to
  1167.      Specify Files: Files.).
  1168.  
  1169.    If you are running your program in an execution environment that
  1170. supports processes, `run' creates an inferior process and makes that
  1171. process run your program.  (In environments without processes, `run'
  1172. jumps to the start of your program.)
  1173.  
  1174.    The execution of a program is affected by certain information it
  1175. receives from its superior.  GDB provides ways to specify this
  1176. information, which you must do *before* starting your program.  (You
  1177. can change it after starting your program, but such changes will only
  1178. affect your program the next time you start it.)  This information may
  1179. be divided into four categories:
  1180.  
  1181. The *arguments.*
  1182.      Specify the arguments to give your program as the arguments of the
  1183.      `run' command.  If a shell is available on your target, the shell
  1184.      is used to pass the arguments, so that you may use normal
  1185.      conventions (such as wildcard expansion or variable substitution)
  1186.      in describing the arguments.  In Unix systems, you can control
  1187.      which shell is used with the `SHELL' environment variable. *Note
  1188.      Your Program's Arguments: Arguments.
  1189.  
  1190. The *environment.*
  1191.      Your program normally inherits its environment from GDB, but you
  1192.      can use the GDB commands `set environment' and `unset
  1193.      environment' to change parts of the environment that will be
  1194.      given to your program.  *Note Your Program's Environment:
  1195.      Environment.
  1196.  
  1197. The *working directory.*
  1198.      Your program inherits its working directory from GDB.  You can set
  1199.      GDB's working directory with the `cd' command in GDB.  *Note Your
  1200.      Program's Working Directory: Working Directory.
  1201.  
  1202. The *standard input and output.*
  1203.      Your program normally uses the same device for standard input and
  1204.      standard output as GDB is using.  You can redirect input and
  1205.      output in the `run' command line, or you can use the `tty'
  1206.      command to set a different device for your program.  *Note Your
  1207.      Program's Input and Output: Input/Output.
  1208.  
  1209.      *Warning:* While input and output redirection work, you cannot use
  1210.      pipes to pass the output of the program you are debugging to
  1211.      another program; if you attempt this, GDB is likely to wind up
  1212.      debugging the wrong program.
  1213.  
  1214.    When you issue the `run' command, your program begins to execute
  1215. immediately.  *Note Stopping and Continuing: Stopping, for discussion
  1216. of how to arrange for your program to stop.  Once your program has
  1217. been started by the `run' command (and then stopped), you may evaluate
  1218. expressions that involve calls to functions in your program, using the
  1219. `print' or `call' commands.  *Note Examining Data: Data.
  1220.  
  1221.    If the modification time of your symbol file has changed since the
  1222. last time GDB read its symbols, GDB will discard its symbol table and
  1223. re-read it.  When it does this, GDB tries to retain your current
  1224. breakpoints.
  1225.  
  1226. 
  1227. File: gdb.info,  Node: Arguments,  Next: Environment,  Prev: Starting,  Up: Running
  1228.  
  1229. Your Program's Arguments
  1230. ========================
  1231.  
  1232.    The arguments to your program can be specified by the arguments of
  1233. the `run' command.  They are passed to a shell, which expands wildcard
  1234. characters and performs redirection of I/O, and thence to your program. 
  1235. GDB uses the shell indicated by your environment variable `SHELL' if
  1236. it exists; otherwise, GDB uses `/bin/sh'.
  1237.  
  1238.    `run' with no arguments uses the same arguments used by the previous
  1239. `run', or those set by the `set args' command.
  1240.  
  1241. `set args'
  1242.      Specify the arguments to be used the next time your program is
  1243.      run.  If `set args' has no arguments, `run' will execute your
  1244.      program with no arguments.  Once you have run your program with
  1245.      arguments, using `set args' before the next `run' is the only way
  1246.      to run it again without arguments.
  1247.  
  1248. `show args'
  1249.      Show the arguments to give your program when it is started.
  1250.  
  1251. 
  1252. File: gdb.info,  Node: Environment,  Next: Working Directory,  Prev: Arguments,  Up: Running
  1253.  
  1254. Your Program's Environment
  1255. ==========================
  1256.  
  1257.    The "environment" consists of a set of environment variables and
  1258. their values.  Environment variables conventionally record such things
  1259. as your user name, your home directory, your terminal type, and your
  1260. search path for programs to run.  Usually you set up environment
  1261. variables with the shell and they are inherited by all the other
  1262. programs you run.  When debugging, it can be useful to try running
  1263. your program with a modified environment without having to start GDB
  1264. over again.
  1265.  
  1266. `path DIRECTORY'
  1267.      Add DIRECTORY to the front of the `PATH' environment variable
  1268.      (the search path for executables), for both GDB and your program. 
  1269.      You may specify several directory names, separated by `:' or
  1270.      whitespace.  If DIRECTORY is already in the path, it is moved to
  1271.      the front, so it will be searched sooner.
  1272.  
  1273.      You can use the string `$cwd' to refer to whatever is the current
  1274.      working directory at the time GDB searches the path.  If you use
  1275.      `.' instead, it refers to the directory where you executed the
  1276.      `path' command.  GDB fills in the current path where needed in
  1277.      the DIRECTORY argument, before adding it to the search path.
  1278.  
  1279. `show paths'
  1280.      Display the list of search paths for executables (the `PATH'
  1281.      environment variable).
  1282.  
  1283. `show environment [VARNAME]'
  1284.      Print the value of environment variable VARNAME to be given to
  1285.      your program when it starts.  If you do not supply VARNAME, print
  1286.      the names and values of all environment variables to be given to
  1287.      your program.  You can abbreviate `environment' as `env'.
  1288.  
  1289. `set environment VARNAME [=] VALUE'
  1290.      Sets environment variable VARNAME to VALUE.  The value changes
  1291.      for your program only, not for GDB itself.  VALUE may be any
  1292.      string; the values of environment variables are just strings, and
  1293.      any interpretation is supplied by your program itself.  The VALUE
  1294.      parameter is optional; if it is eliminated, the variable is set
  1295.      to a null value.
  1296.  
  1297.      For example, this command:
  1298.  
  1299.           set env USER = foo
  1300.  
  1301.      tells a Unix program, when subsequently run, that its user is
  1302.      named `foo'.  (The spaces around `=' are used for clarity here;
  1303.      they are not actually required.)
  1304.  
  1305. `unset environment VARNAME'
  1306.      Remove variable VARNAME from the environment to be passed to your
  1307.      program.  This is different from `set env VARNAME ='; `unset
  1308.      environment' removes the variable from the environment, rather
  1309.      than assigning it an empty value.
  1310.  
  1311. 
  1312. File: gdb.info,  Node: Working Directory,  Next: Input/Output,  Prev: Environment,  Up: Running
  1313.  
  1314. Your Program's Working Directory
  1315. ================================
  1316.  
  1317.    Each time you start your program with `run', it inherits its
  1318. working directory from the current working directory of GDB.  GDB's
  1319. working directory is initially whatever it inherited from its parent
  1320. process (typically the shell), but you can specify a new working
  1321. directory in GDB with the `cd' command.
  1322.  
  1323.    The GDB working directory also serves as a default for the commands
  1324. that specify files for GDB to operate on.  *Note Commands to Specify
  1325. Files: Files.
  1326.  
  1327. `cd DIRECTORY'
  1328.      Set GDB's working directory to DIRECTORY.
  1329.  
  1330. `pwd'
  1331.      Print GDB's working directory.
  1332.  
  1333.